package com.cheche.dn.domain;

import org.springframework.http.HttpMethod;

public interface Apis {

    final class Mapping {
        String url;
        HttpMethod method;

        public Mapping(String url) {
            this.url = url;
        }

        public Mapping(String url, HttpMethod method) {
            this.url = url;
            this.method = method;
        }

        public String getUrl() {
            return url;
        }

        public HttpMethod getMethod() {
            return method;
        }
    }

    String ROOT_URL = "/";
    String AUTHENTICATE_URL = "/authenticate";
    String LOGOUT_URL = "/logout";
    Mapping ROOT = new Mapping("/");

    // Spring Boot Actuator services
    String ACTUATOR_ENDPOINT = "/actuator";                 //Sensitive true
    String AUTOCONFIG_ENDPOINT = "/autoconfig";             //Sensitive true
    String BEANS_ENDPOINT = "/beans";                       //Sensitive true
    String CONFIGPROPS_ENDPOINT = "/configprops";           //Sensitive true
    String DUMP_ENDPOINT = "/dump";                         //Sensitive true
    String ENV_ENDPOINT = "/env";                           //Sensitive true
    String FLYWAY_ENDPOINT = "/flyway";                     //Sensitive true
    String HEALTH_ENDPOINT = "/health";                     //Sensitive false
    String INFO_ENDPOINT = "/info";                         //Sensitive false
    String LIQUIBASE_ENDPOINT = "/liquibase";               //Sensitive true
    String LOGFILE_ENDPOINT = "/logfile";                   //Sensitive true
    String MAPPINGS_ENDPOINT = "/mappings";                 //Sensitive true
    String METRICS_ENDPOINT = "/metrics";                   //Sensitive true
    String SHUTDOWN_ENDPOINT = "/shutdown";                 //Sensitive true
    String TRACE_ENDPOINT = "/trace";                       //Sensitive true
    String[] SUPER_ADMIN_URL = {
            ACTUATOR_ENDPOINT, AUTOCONFIG_ENDPOINT, BEANS_ENDPOINT, CONFIGPROPS_ENDPOINT, DUMP_ENDPOINT,
            ENV_ENDPOINT, FLYWAY_ENDPOINT, HEALTH_ENDPOINT, INFO_ENDPOINT, LIQUIBASE_ENDPOINT, LOGFILE_ENDPOINT,
            MAPPINGS_ENDPOINT, METRICS_ENDPOINT, SHUTDOWN_ENDPOINT, TRACE_ENDPOINT
    };
    // Set<String> ACTUATOR_ENDPOINTS_VALUES = Sets.newHashSet(SUPER_ADMIN_URL);

    // URLS
    String ADMINS_URL = "/admins";
    String ADMINS_SELF_URL = "/admins/self";
    String ADMINS_ID_URL = "/admins/{id:[\\d]+}";
    String ADMINS_PASSWORD_URL = "/admins/password";
    String ADMINS_ID_PASSWORD_URL = "/admins/{id:[\\d]+}/password";
    String ADMINS_ID_ROLES_URL = "/admins/{id:[\\d]+}/roles";
    String ROLES_URL = "/roles";
    String ROLES_ID_URL = "/roles/{id:[\\d]+}";
    String ROLES_ID_AUTHORITIES_URL = "/roles/{id:[\\d]+}/authorities";
    String AUTHORITIES_URL = "/authorities";
    String USERS_URL = "/users";
    String USERS_ID_URL = "/users/{id:[\\d]+}";
    String USERS_SELF_URL = "/users/self";

    // MAPPINGS
    Mapping ADMINS_GET_MAPPING = new Mapping(ADMINS_URL, HttpMethod.GET);
    Mapping ADMINS_SELF_GET_MAPPING = new Mapping(ADMINS_SELF_URL, HttpMethod.GET);
    Mapping ADMINS_POST_MAPPING = new Mapping(ADMINS_URL, HttpMethod.POST);
    Mapping ADMINS_ID_GET_MAPPING = new Mapping(ADMINS_ID_URL, HttpMethod.GET);
    Mapping ADMINS_PASSWORD_PATCH_MAPPING = new Mapping(ADMINS_PASSWORD_URL, HttpMethod.PATCH);
    Mapping ADMINS_ID_PASSWORD_PATCH_MAPPING = new Mapping(ADMINS_ID_PASSWORD_URL, HttpMethod.PATCH);
    Mapping ADMINS_ID_ROLES_POST_MAPPING = new Mapping(ADMINS_ID_ROLES_URL, HttpMethod.POST);
    Mapping ADMINS_ID_ROLES_DELETE_MAPPING = new Mapping(ADMINS_ID_ROLES_URL, HttpMethod.DELETE);
    Mapping AUTHORITIES_GET_MAPPING = new Mapping(AUTHORITIES_URL, HttpMethod.GET);
    Mapping ROLES_POST_MAPPING = new Mapping(ROLES_URL, HttpMethod.POST);
    Mapping ROLES_GET_MAPPING = new Mapping(ROLES_URL, HttpMethod.GET);
    Mapping ROLES_PUT_MAPPING = new Mapping(ROLES_URL, HttpMethod.PUT);
    Mapping ROLES_ID_AUTHORITIES_POST_MAPPING = new Mapping(ROLES_ID_AUTHORITIES_URL, HttpMethod.POST);
    Mapping ROLES_ID_AUTHORITIES_DELETE_MAPPING = new Mapping(ROLES_ID_AUTHORITIES_URL, HttpMethod.DELETE);
    Mapping ROLES_DELETE_MAPPING = new Mapping(ROLES_URL, HttpMethod.DELETE);
    Mapping ROLES_ID_DELETE_MAPPING = new Mapping(ROLES_ID_URL, HttpMethod.DELETE);
    Mapping ROLES_ID_GET_MAPPING = new Mapping(ROLES_ID_URL, HttpMethod.GET);
    Mapping USERS_GET_MAPPING = new Mapping(USERS_URL, HttpMethod.GET);
    Mapping USERS_POST_MAPPING = new Mapping(USERS_URL, HttpMethod.POST);

    // test
    String TEST_URL = "/test";

    Mapping[] OPEN_MAPPINGS = {
            ROOT, new Mapping("/favicon.ico"), new Mapping("/static/**"), new Mapping(TEST_URL)
    };
}
